<template>
	<view class="con">
		<!-- 顶部标题 -->
		<view class="title">
			<text>根据相关规定，保护你的合法权益，需要进行实名认证</text>
		</view>
		<!-- 输入框 -->
		<view class="inp">
			<view class="box">
				<view class="box-con">
					<view class="box-title">
						<text style="color: red;">*</text>
						<text>身份证姓名</text>
					</view>
					<view class="box-inp">
						<input placeholder="请输入姓名" v-model="name" />
					</view>
				</view>
			</view>
			<view class="box">
				<view class="box-con">
					<view class="box-title">
						<text style="color: red;">*</text>
						<text>身份证号码</text>
					</view>
					<view class="box-inp">
						<input placeholder="请输入身份证号码" v-model="idCard" />
					</view>
				</view>
			</view>
			<view class="box">
				<view class="box-con">
					<view class="box-title">
						<text style="color: red;">*</text>
						<text>设置支付密码</text>
					</view>
					<view class="box-inp">
						<input type="number" maxlength="6" placeholder="请输入支付密码" v-model="password" />
					</view>
				</view>
			</view>
		</view>

		<!-- 消息提示 -->
		<view class="tips">
			<text>您提供的证件信息受到严格保护，仅用于身份验证未经本人允许不会用于其他用途。</text>
		</view>

		<!-- 认证按钮 -->
		<view class="btn">
			<view class="btn-box" @click="identityClick">
				<text>确定</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		identifyCheck
	} from '@/api/http/main/my/community.js'

	export default {
		data() {
			return {
				name: '',
				idCard: '',
				password: ''
			}
		},
		methods: {
			identityClick() {
				if (this.name == '' || this.idCard == '' || this.password == '' || this.password.length < 6) {
					return uni.$showMsg('请输入正确参数！');
				}

				var that = this
				identifyCheck(this.name, this.idCard, this.password).then(res => {
					if (res.data.pubInfo.code !== 0) {
						that.$emit('changeState', true)
						return uni.$showMsg(res.data.pubInfo.message);
					}
					uni.setStorageSync('identifyCheck', true)
					uni.$showMsg('认证成功')
					that.$emit('changeState', false)
				})

				//修改状态
				//this.$emit('changeState', false)

			}
		}
	}
</script>

<style scoped lang="scss">
	.con {
		.title {
			padding-top: 30rpx;
			width: 70%;
			margin-left: 15%;
			text-align: center;
			// height: 150rpx;
			// line-height: 150rpx;

			text {
				font-size: 36rpx;
				font-weight: 400;
				color: rgba(128, 128, 128, 1);
			}

		}

		.inp {
			margin-top: 100rpx;

			.box {
				border-bottom: 2rpx solid rgba(229, 229, 229, 1);
				margin: 40rpx 0;

				.box-con {
					width: 90%;
					margin-left: 5%;
				}

				.box-title {
					font-size: 36rpx;
					font-weight: 400;
					color: rgba(0, 0, 0, 1);

				}

				.box-inp {
					width: 90%;
					margin: 20rpx 0;
					font-size: 36rpx;
					font-weight: 400;
				}
			}
		}

		.tips {
			width: 80%;
			margin-left: 10%;
			margin-top: 60rpx;
			text-align: center;
			font-size: 30rpx;
			font-weight: 400;
			color: rgba(166, 166, 166, 1);
		}

		.btn {
			position: fixed;
			z-index: 9;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 160rpx;

			.btn-box {
				width: 80%;
				margin-left: 10%;
				height: 100rpx;
				background-color: rgba(42, 130, 228, 1);
				color: #ffffff;
				border-radius: 60rpx;
				text-align: center;
				line-height: 100rpx;
				font-size: 40rpx;
			}
		}
	}
</style>